$(function () {
    var fn = ABUS.Fn;
    var param = window.__param__;
    var _ = window._;
    var listData = [];

    document.addEventListener('touchmove', function (e) {
        isDrag = true;
        e.preventDefault();
    }, {passive: false});

    $("#being_process").on("touchend", "li", function () {
        if (isDrag) {
            isDrag = false;
            return true;
        }
        var data = listData[$(this).index()];
        data.p1 = $(this).data("p1");
        data.p2 = $(this).data("p2");
        fn.page_goto({
            url : "./yewuyuan_banli_startTask.html",
            data : data
        })
    });

    $('#searchInput').on('input', _.debounce(function (e) {
        var str = $(this).val();
        init(str)
    },500));

    init("");
    function init(val) {
        fn.get({
            url: "/user/order/acceptedChildOrders",
            data: {
                "searchValue": val,
                "orderBy": "",//1业务类型 2剩余时间 3开始时间
                "orderType": ""
            },
            success: function (data) {
                $("#being_process").renderTemp(data);
                listData = data.data;
                new IScroll('#being_process', {mouseWheel: true});
                $('#being_process').find('li').each(function () {
                    var $el = $(this).find('[data-time]');
                    if ($el.length > 0 && $el.data('time'))
                        fn.countDown($el.data('time'), function (time) {
                            $el.text(time)
                        })
                    var $el1 = $(this).find('[data-time1]');
                    if ($el1.length > 0 && $el1.data('time1'))
                        fn.countDown($el1.data('time1'), function (time,min) {
                            $el1.text("余:"+min+"分钟")
                        })
                })
            }
        });
    }
});